import React, { Component } from 'react';
import { Route, NavLink } from 'react-router-dom';
import PropTypes from 'prop-types';

import  "./Page1.css";

class Page1 extends Component {

    // 定义 contextTypes ，以使该组件能够接收到  context
    static contextTypes = {
        pushNavConfig: PropTypes.func,
        popNavConfig: PropTypes.func,
    };

    configID;

    navConfig = {
        left: "1左",
        center: "页面1",
        right:"1右",
        navClass: "page1_nav"
    };
    
    componentWillMount() {
        this.configID = this.context.pushNavConfig(this.navConfig);      //设置导航条
    }

    componentWillUnmount() {
        this.context.popNavConfig(this.configID);       //移除对导航条的设置
    }

    render() {
        return (
            <fieldset className="page1" >
                <legend>页面1</legend>
                <br />
                <NavLink to={"/custom_item/page2"} >跳转到:页面2</NavLink>
                <br />
                <NavLink to={"/custom_item"} >返回:默认页</NavLink>
            </fieldset>
        );
    }
}



export {Page1};